// id_generator.go

package utils

import (
	"sync"
)

// IDGenerator 全局 ID 生成器
var IDGenerator = NewRoomIDGenerator()

type RoomIDGenerator struct {
	mu      sync.Mutex
	counter int
}

func NewRoomIDGenerator() *RoomIDGenerator {
	return &RoomIDGenerator{}
}

func (g *RoomIDGenerator) GenerateRoomID() int {
	g.mu.Lock()
	defer g.mu.Unlock()
	g.counter++
	return g.counter
}
